//
//  DetailView.swift
//  shop
//
//  Created by chen on 2025/5/14.
//

import SwiftUI

struct DetailView: View {
    
    @EnvironmentObject private var router: Router
    @StateObject private var vm: DetailViewModel = DetailViewModel()
    
    var id: Int64
    
    var body: some View {
        ZStack{
            Color.detailBg
                .ignoresSafeArea()
            
            VStack(spacing: 0) {
                CommonHeader(title: "商品详情")
                
                ScrollView(showsIndicators: false) {
                    VStack(spacing: 0) {
                        DetailBanner(vm: vm)
                        
                        DetailDesc(router: router, vm: vm)
                        
                        DetailLike(router: router, vm: vm)
                    }
                }
                
                // 底部按钮
                DetailFooter(vm: vm)
            }
        }
        .navigationBarBackButtonHidden(true)
        .onAppear {
            vm.getGoodsDetail(id: id)
        }
    }
}

#Preview {
    DetailView(id: 45055773)
        .environmentObject(Router.shared)
}
